﻿using System;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Kcadastro.classes;

namespace Kcadastro.adm
{
    public partial class billing_list : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //TODO: BEGIN Seleciona Link Serviços
            if (this.Master is kcadastro)
            {
                ((kcadastro)this.Page.Master).SelecionaPagina(FW.utils.enumPaginas.Billing);
            }
            //TODO:END
            if (!IsPostBack)
            {
                carregar();
            }
        }

        private void carregar()
        {
            bt_carregar.Enabled = false;
            bill bil = new bill();
            dd_anos.DataSource = bil.verificaAnos();
            dd_anos.DataBind();

            if (dd_anos.Items.Count > 0) bt_carregar.Enabled = true;
        }

        protected void bt_carregar_Click(object sender, EventArgs e)
        {
            bill bil = new bill();
            gv_lista.DataSource = bil.listarFechMes(Convert.ToInt16(dd_anos.SelectedValue), Convert.ToInt16(dd_mes.SelectedValue));
            gv_lista.DataBind();

        }

        protected void gv_lista_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.ToString() == "visualizar")
            {
                int ind = Convert.ToInt32(e.CommandArgument);
                DataKey data = gv_lista.DataKeys[ind];
                //Session.Add("IDuuser", data.Values["PK_IDuser"].ToString());
                Response.Redirect("billing_relat.aspx?i=" + data.Values["PKBILL"].ToString(), true); //?id=" + data.Values["PK_IDos"].ToString()
            }
        }
    }
}